package function;

import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import login.LoginFrame;

public class PropertyFrame extends JFrame{
	
	private JButton b_user,b_bill,b_house,b_newproperty,b_exit;//业主管理，费用管理，房间管理，新增物业
	private JLabel l_hello,l_content,l_content1,l_content2,l_content3;//文本
	
	public PropertyFrame() {
		this.setSize(600,500);
		this.setTitle("物业界面");
		this.setLocation(500,150);
		init();
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	public void init() {
		Font fontBB = new Font("宋体",Font.BOLD,25);
		Font fontB = new Font("宋体",Font.BOLD,12);
		b_user = new JButton("业主管理");
		b_user.setFont(fontB);
		b_user.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				new MUserFrame("select * from user");
			}
			
		});
		b_bill = new JButton("费用管理");
		b_bill.setFont(fontB);
		b_bill.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				new MBillFrame("select user.id,name,age,user.uno,user.hno,水费,电费,燃气费,取暖费,物业费,房租 from user,bill,house where user.hno = house.hno and bill.id = user.id and type = '业主' and (水费!=0 OR 电费!=0 OR 燃气费!=0 OR 取暖费!=0 OR 物业费!=0 OR 房租!=0)");
			}
			
		});
		b_house = new JButton("房间管理");
		b_house.setFont(fontB);
		b_house.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				new MHouseFrame("select * from house");
			}
			
		});
		b_newproperty = new JButton("新增物业");
		b_newproperty.setFont(fontB);
		b_newproperty.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				new MRegisterFrame();
			}
			
		});
		
		b_exit = new JButton ("退出登录");
		b_exit.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				new LoginFrame();
				setVisible(false);
			}
			
		});
		
		l_hello = new JLabel("您好，",JLabel.CENTER);
		l_hello.setFont(fontBB);
		l_content = new JLabel("尊敬的物业先生！",JLabel.CENTER);
		l_content.setFont(fontBB);
		l_content1 = new JLabel("欢迎使用物业系统，您可在此进行管理",JLabel.CENTER);
		l_content1.setFont(fontBB);
		l_content2 = new JLabel("业主和费用信息！",JLabel.CENTER);
		l_content2.setFont(fontBB);
		l_content3 = new JLabel("祝您生活愉快！",JLabel.CENTER);
		l_content3.setFont(fontBB);
		this.setLayout(null);
		JPanel p = new JPanel();
		p.setLayout(new GridLayout(1,5,5,5));
		p.add(b_user);
		p.add(b_bill);
		p.add(b_newproperty);
		p.add(b_house);
		p.add(b_exit);
		p.setBounds(15,10,550,30);
		this.add(p);
		
		p = new JPanel();
		p.add(l_hello);
		p.setBounds(20,60,100,50);
		this.add(p);
		
		p = new JPanel();
		p.add(l_content);
		p.setBounds(20,135,350,50);
		this.add(p);
		
		p = new JPanel();
		p.add(l_content1);
		p.setBounds(60,195,500,50);
		this.add(p);
		
		p = new JPanel();
		p.add(l_content2);
		p.setBounds(15,255,240,50);
		this.add(p);
		
		p = new JPanel();
		p.add(l_content3);
		p.setBounds(280,350,350,50);
		this.add(p);
		
	}
	
}
